<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue 3 加减计数器（选项式 API）</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        .counter-container {
            display: flex;
            align-items: center;
            background: #fff;
            padding: 10px;
            border-radius: 5px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        .counter-button {
            font-size: 24px;
            padding: 10px 20px;
            cursor: pointer;
            background: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
        }
        .counter-button:hover {
            background: #0056b3;
        }
        .counter-display {
            font-size: 24px;
            margin: 0 20px;
            font-weight: bold;
            color: #333;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="counter-container">
            <button class="counter-button" @click="decrement">-</button>
            <div class="counter-display">{{ counter }}</div>
            <button class="counter-button" @click="increment">+</button>
        </div>
    </div>

    <!-- 引入 Vue 3 -->
    <script src="https://unpkg.com/vue@3"></script>
    <script>
        Vue.createApp({
            data() {
                return {
                    counter: 0  // 定义一个数据属性，用于存储计数值
                };
            },
            methods: {
                increment() {
                    this.counter += 1;  // 增加计数
                },
                decrement() {
                    this.counter -= 1;  // 减少计数
                }
            }
        }).mount('#app');
    </script>
</body>
</html>